cmake_minimum_required(VERSION 2.8)
project(Base)
message("===== Base =====")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Release)
endif()

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") 

ADD_DEFINITIONS(
        -Wno-unused-value
        -Wno-format
        -Wno-format-security
        -Wno-unused-variable
        -Wno-unused-but-set-variable
)

ADD_DEFINITIONS(-Wall
        -fwide-exec-charset=UTF-16LE
        -fsigned-char
        -fpic
        -fno-short-enums
        -fshort-wchar
        -std=c++11
        -fexceptions
)

ADD_DEFINITIONS(-DMAPBAR_OS_UNIX)

if( NOT DEFINED MODULE_OUT_PATH )
  set( MODULE_OUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/module/ )
endif()
set( LIBRARY_OUTPUT_PATH ${MODULE_OUT_PATH} )

# Opencv
if( NOT OpenCV_FOUND)
  find_package(OpenCV 4 REQUIRED)
  if( OpenCV_FOUND )
      message( "Opencv lib is found:" ${OpenCV_INCLUDE_DIRS} )
  endif()
endif()

# Eigen
find_package(Eigen3 REQUIRED)
find_package(rapidjson REQUIRED)

FILE(GLOB SOURCE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

add_library(${PROJECT_NAME} SHARED ${SOURCE_FILE})

target_include_directories(${PROJECT_NAME} 
    PUBLIC
        ${PROJECT_SOURCE_DIR}
        ${EIGEN3_INCLUDE_DIR}
        ${RAPIDJSON_INCLUDE_DIRS}
)

target_link_libraries(${PROJECT_NAME}
    "/usr/local/lib/libproj.so"
    ${OpenCV_LIBS}
)
